import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:package_info/package_info.dart';
import 'function.dart';

class AboutPage extends StatefulWidget {
  AboutPage(this.mainColor);
  final Color mainColor;
  @override
  _AboutPageState createState() => new _AboutPageState();
}

class PluginInfo {
  PluginInfo(this.name, this.url, this.author);
  String name;
  String url;
  String author;
}

List<PluginInfo> plugins = [
  new PluginInfo("Dio", "https://github.com/flutterchina/dio", "flutterchina"),
  new PluginInfo("FlutterToast", "https://github.com/PonnamKarthik/FlutterToast", "PonnamKarthik"),
  new PluginInfo("sqflite", "https://github.com/tekartik/sqflite", "tekartik"),
  new PluginInfo("flutter_pulltorefresh", "https://github.com/peng8350/flutter_pulltorefresh", "peng8350"),
  new PluginInfo("shared_preferences", "https://github.com/flutter/plugins/tree/master/packages/shared_preferences", "Flutter"),
  new PluginInfo("fcharts", "https://github.com/thekeenant/fcharts", "thekeenant"),
  new PluginInfo("flutter_qq", "https://github.com/marekchen/flutter_qq", "marekchen"),
  new PluginInfo("url_launcher", "https://github.com/flutter/plugins/tree/master/packages/url_launcher", "Flutter"),
  new PluginInfo("flutter_statusbar_manager", "https://github.com/FooStudio/flutter_statusbar_manager", "FooStudio"),
  new PluginInfo("qr_flutter", "https://github.com/lukef/qr.flutter", "lukef"),
  new PluginInfo("event_bus", "https://github.com/marcojakob/dart-event-bus", "marcojakob"),
  new PluginInfo("flutter_html", "https://github.com/Sub6Resources/flutter_html", "Sub6Resources"),
  new PluginInfo("gesture_password", "https://github.com/OpenFlutter/flutter_gesture_password", "JarvanMo"),
  new PluginInfo("flutter_colorpicker", "https://github.com/mchome/flutter_colorpicker", "mchome"),
  new PluginInfo("local_auth", "https://github.com/flutter/plugins/tree/master/packages/local_auth", "Flutter"),
  new PluginInfo("device_info", "https://github.com/flutter/plugins/tree/master/packages/device_info", "Flutter"),
  new PluginInfo("path_provider", "https://github.com/flutter/plugins/tree/master/packages/path_provider", "Flutter"),
  new PluginInfo("flutter_jpush", "https://github.com/best-flutter/flutter_jpush", "jzoom"),
  new PluginInfo("package_info", "https://github.com/flutter/plugins/tree/master/packages/package_info", "Flutter"),
  new PluginInfo("tobias", "https://github.com/OpenFlutter/tobias", "JarvanMo"),
  new PluginInfo("barcode_scan", "https://github.com/apptreesoftware/flutter_barcode_reader", "matthewtsmith"),
];

//List<String> rewards=[
//  "huzi","152****3000","One","路漫漫","我是一只鱼","hitlerzhan","超级老蜜蜂","jason","泛泛之辈","悠扬海","致远通信","xiaoc","雨中情缘","小光","Aluka","郁闷的類","天顺小刘","其他匿名朋友"
//];
class _AboutPageState extends State<AboutPage> {
  String version = "";
  String buildNumber = "";
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
      version = packageInfo.version;
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: new CupertinoNavigationBar(
        actionsForegroundColor: Colors.white,
        backgroundColor: widget.mainColor,
        border: new Border(bottom: BorderSide.none),
        middle: new Text(
          "关于随行",
          style: new TextStyle(
            color: Colors.white,
            fontWeight: FontWeight.normal,
          ),
        ),
      ),
      body: new Scrollbar(
        child: new ListView(
          children: <Widget>[
            new Container(
              child: new Column(
                children: <Widget>[
                  new SizedBox(
                    height: 20.0,
                  ),
                  new Image.asset(
                    "images/icon.png",
                    width: 100.0,
                  ),
                  new SizedBox(
                    height: 10.0,
                  ),
                  new Text(
                    "玩客随行 V$version",
                    style: new TextStyle(fontSize: 18.0),
                  ),
                  new Text(
                    "Powered By Flutter",
                    style: new TextStyle(color: Colors.black38),
                  ),
                  new SizedBox(
                    height: 20.0,
                  ),
                ],
              ),
            ),
            new ExpansionTile(
              title: new Text("随行介绍"),
              children: <Widget>[
                new Container(
                  padding: new EdgeInsets.all(10.0),
                  child: new Text(
                    '        玩客随行是一款基于《玩客云》官方客户端开发的玩客云管理APP，可以绑定多个账号，查看收入统计、可提链克、历史收入、提币记录、一键提币、分组管理等功能，方便快捷，是手机管理玩客云的必备神器，且永久免费！\n'
                        '        玩客随行APP中所添加的账号信息在不使用实时监控功能时，完全存储在本地。使用实时监控功能时，需要将账号信息上传至服务器，传输过程是加密的，请放心使用',
                    softWrap: true,
                    style: new TextStyle(fontSize: 16.0),
                  ),
                ),
              ],
            ),
            new ExpansionTile(
              title: new Text("版本信息"),
              children: <Widget>[
                new Container(
                  padding: new EdgeInsets.all(10.0),
                  child: new Text(
                    "        全新UI，流畅体验，玩客随行2.0版本正式上线，欢迎体验。\n"
                        "        更新内容：\n"
                        "        1.使用Google开源项目Flutter，打造更加流畅的操作体验。\n"
                        "        2.设备页面布局优化，重要信息一目了然。\n"
                        "        3.启动密码更换为手势密码/指纹验证\n"
                        "        4.主题设置全局有效\n"
                        "        尚未完成：\n"
                        "        1.实时监控\n"
                        "        4.手机号登录\n",
                    softWrap: true,
                    style: new TextStyle(fontSize: 16.0),
                  ),
                ),
              ],
            ),
            new ExpansionTile(
              title: new Text("开源信息"),
              children: plugins.map((plugin) {
                return new Container(
                  child: new Column(
                    children: <Widget>[
                      ListTile(
                        onTap: () {
                          launch(plugin.url);
                        },
                        title: new Row(
                          children: <Widget>[
                            new Expanded(child: new Text(plugin.name)),
                          ],
                        ),
                        subtitle: new Text(plugin.author),
                        trailing: new Icon(Icons.chevron_right),
                      ),
                      new Divider(
                        height: 1.0,
                      )
                    ],
                  ),
                );
              }).toList(),
            ),
            new ExpansionTile(
              title: new Text("捐赠打赏"),
              children: <Widget>[
                new Container(
                  padding: new EdgeInsets.all(10.0),
                  child: new Column(
                    children: <Widget>[
                      new ListTile(
                        title: new Text("链克打赏"),
                        trailing: new FlatButton(
                          onPressed: () {
                            Clipboard.setData(new ClipboardData(text: "0x4290d725a5ea1f83e81486aa1e230747fd281137"));
                            toast("已复制");
                          },
                          child: new Text("复制地址"),
                        ),
                      ),
                      new ListTile(
                        title: new Text("支付宝打赏"),
                        trailing: new FlatButton(
                          onPressed: () {
                            Clipboard.setData(new ClipboardData(text: "18953292540"));
                            toast("已复制");
                          },
                          child: new Text("复制账号"),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
